package BehaviorModel.mementoModel;

public class ClientMementoTest {
    public static void main(String[] args) {
        Caretaker caretaker = new Caretaker();
        Originator originator = new Originator();
        originator.setState("state#1, 攻击力100");

        // 保存状态至管理者
        caretaker.add(originator.createMemento());

        originator.setState("state#2, 攻击力50");
        caretaker.add(originator.createMemento());

        originator.setState("state#3, 攻击力0");
        caretaker.add(originator.createMemento());

        System.out.println("初始状态：" + originator.getState());

        // 恢复到之前的状态
        originator.restoreMemento( caretaker.get(1));
        System.out.println("回滚后状态：" + originator.getState());
    }
}
